if(BOOTLOADER STREQUAL "EMPTY" OR BOOTLOADER)
  set(BOOT_SUFFIX "_boot")
else()
  set(BOOT_SUFFIX "")
endif()

if(MCU MATCHES "STM32F4")
  add_subdirectory(stm32f4)
  if(MCU MATCHES "STM32F40")
    set(STM32F4_HAL_TARGET "STM32F407xx")
  elseif(MCU MATCHES "STM32F42")
    set(STM32F4_HAL_TARGET "STM32F427xx")
  else()
    message(FATAL_ERROR "Don't know how to configure STM32F4::HAL for mcu ${MCU}")
  endif()
  add_library(STM32F4_HAL_Config INTERFACE)
  target_compile_definitions(STM32F4_HAL_Config INTERFACE ${STM32F4_HAL_TARGET} USE_HAL_DRIVER)
  target_include_directories(STM32F4_HAL_Config INTERFACE ${CMAKE_SOURCE_DIR}/include/stm32f4_hal)
elseif(MCU MATCHES "STM32G0")
  add_subdirectory(stm32g0)
  add_library(STM32G0_HAL_Config INTERFACE)
  target_compile_definitions(STM32G0_HAL_Config INTERFACE STM32G070xx USE_HAL_DRIVER)
  target_include_directories(STM32G0_HAL_Config INTERFACE ${CMAKE_SOURCE_DIR}/include/stm32g0_hal)
elseif(MCU MATCHES "STM32H5")
  add_subdirectory(stm32h5)
  add_library(STM32H5_HAL_Config INTERFACE)
  target_compile_definitions(STM32H5_HAL_Config INTERFACE STM32H503xx USE_HAL_DRIVER)
  target_include_directories(STM32H5_HAL_Config INTERFACE ${CMAKE_SOURCE_DIR}/include/stm32h5_hal)
else()
  message(FATAL_ERROR "Unknown subdirectory for ${MCU}")
endif()

add_library(FreeRTOS_Config INTERFACE)
target_link_libraries(FreeRTOS_Config INTERFACE Segger BuddyHeaders)
